/**
 * JAVACC DEMO 1.0
 * @copy right iussoft company All rights reserved.
 * @Package com.apache.audit.service.plugins  
 */
package com.apache.audit.service.plugins;

import java.util.List;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.audit.entity.LogOperation;
import com.apache.audit.manager.LogOperationManager;
import com.apache.cache.util.Validator;
import com.apache.database.model.Page;
import com.apache.tools.ClassToolsUtil;

/**
 * description:  审记操作记录信息列表
 * @author dyhou 创建时间：2016-7-11  
 */
public class LogOperationListPluginImpl implements PluginConnector {

	private LogOperationManager logOperationManager;

	/**
	 * TODO 审记操作记录信息列表 
	 */
	public Object execute(ParamsVo param) throws Exception {
		ResultEntity entity = new ResultEntity();
		entity.setResult("true");

		LogOperation deal = new LogOperation();
		deal = (LogOperation) ClassToolsUtil.getInstance().convert2Bean(param.getParams(), deal);
		ParamsVo<LogOperation> vo = new ParamsVo<LogOperation>();
		vo.setObj(deal);
		vo.setMethodKey("ByService");
		if (Validator.isNotNull(String.valueOf(param.getParams("modelSysname")))) {
			vo.setParams("modelSysname", String.valueOf(param.getParams("modelSysname")));
		}
		if (Validator.isNotNull(String.valueOf(param.getParams("modelBussiness")))) {
			vo.setParams("modelBussiness", String.valueOf(param.getParams("modelBussiness")));
		}
		if (Validator.isNotNull(String.valueOf(param.getParams("modelCname")))) {
			vo.setParams("modelCname", String.valueOf(param.getParams("modelCname")));
		}
		if (Validator.isNotNull(String.valueOf(param.getParams("createdTime")))) {//格式2015-04-21
			vo.setParams("createdTime", String.valueOf(param.getParams("createdTime")));
		}
		String rows = Validator.getDefaultStr(String.valueOf(param.getParams("rows")), "0");
		if ("0".equals(rows)) {
			List list = logOperationManager.getList(vo);
			entity.setEntity(list);
		} else {
			String page = Validator.getDefaultStr(String.valueOf(param.getParams("page")), "1");
			vo.setParams("pageIndex", page);
			vo.setParams("pageSize", rows);
			Page pageList = logOperationManager.getPageInfo(vo);
			entity.setEntity(pageList);
		}
		entity.setMessage("查询成功");
		return entity;
	}

	public void setLogOperationManager(LogOperationManager logOperationManager) {
		this.logOperationManager = logOperationManager;
	}

}
